package cn.hicard.risk.dao.bd.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.hicard.core.Page;
import cn.hicard.core.PageResult;
import cn.hicard.core.Where;
import cn.hicard.risk.dao.BaseDao;
import cn.hicard.risk.dao.bd.BusinessDao;
import cn.hicard.risk.entity.BdBusiness;
import cn.hicard.risk.entity.BdMerchinfo;

@Repository
public class BusinessDaoImpl extends BaseDao<BdBusiness> implements BusinessDao{
	
	@Override
	public PageResult<BdBusiness> search(Where where, Page page) throws Exception {
		 String hql="FROM BdBusiness WHERE 1=1 "+where.queryString();
		 String countHql="SELECT COUNT(*) FROM BdBusiness WHERE 1=1 "+where.queryString();
		 PageResult<BdBusiness> result = new PageResult<BdBusiness>();
		 result.setDataList(super.findByHqlPage(hql, page, where.getParams()));
		 result.setResultCount(super.findCountByHql(countHql, where.getParams()));
	       return result;
	}

	@Override
	public List<BdBusiness>  findList(Where where)
			throws Exception {
		String hql = "FROM BdBusiness WHERE 1=1 "+where.queryString();
		return super.findByHql(hql, where.getParams());
	}
	
	/**
	 * 查询清算周期为T+2的商户号列表
	 */
	public List<String> findPeriodList(BdBusiness bus) throws Exception {
		String hql = "SELECT distinct hmId FROM BdBusiness WHERE reckCycle=?";
		String period = bus.getReckCycle();
		return super.findFieldsByHql(hql,period);
	}
	
}
